package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GzdsBankInfo;
import com.ruoyi.system.service.IGzdsBankInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 题库管理Controller
 * 
 * @author ruoyi
 * @date 2021-04-20
 */
@RestController
@RequestMapping("/system/info")
public class GzdsBankInfoController extends BaseController
{
    @Autowired
    private IGzdsBankInfoService gzdsBankInfoService;

    /**
     * 查询题库管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(GzdsBankInfo gzdsBankInfo)
    {
        startPage();
        List<GzdsBankInfo> list = gzdsBankInfoService.selectGzdsBankInfoList(gzdsBankInfo);
        return getDataTable(list);
    }

    /**
     * 导出题库管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "题库管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GzdsBankInfo gzdsBankInfo)
    {
        List<GzdsBankInfo> list = gzdsBankInfoService.selectGzdsBankInfoList(gzdsBankInfo);
        ExcelUtil<GzdsBankInfo> util = new ExcelUtil<GzdsBankInfo>(GzdsBankInfo.class);
        return util.exportExcel(list, "题库管理数据");
    }

    /**
     * 获取题库管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{bankId}")
    public AjaxResult getInfo(@PathVariable("bankId") Long bankId)
    {
        return AjaxResult.success(gzdsBankInfoService.selectGzdsBankInfoById(bankId));
    }

    /**
     * 新增题库管理
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "题库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GzdsBankInfo gzdsBankInfo)
    {
        return toAjax(gzdsBankInfoService.insertGzdsBankInfo(gzdsBankInfo));
    }

    /**
     * 修改题库管理
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "题库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GzdsBankInfo gzdsBankInfo)
    {
        return toAjax(gzdsBankInfoService.updateGzdsBankInfo(gzdsBankInfo));
    }

    /**
     * 删除题库管理
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "题库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bankIds}")
    public AjaxResult remove(@PathVariable Long[] bankIds)
    {
        return toAjax(gzdsBankInfoService.deleteGzdsBankInfoByIds(bankIds));
    }
}
